#ifndef CONFIGANALYZE_H
#define CONFIGANALYZE_H

#include<QMap>
#include <QFileInfo>
#include <QJsonParseError>
#include<QDebug>
#include <QJsonArray>
#include "configeditor.h"
#include "comboboxmodel.h"
#include"SqlTable/abstractlistmodel.h"
#include "SqlTable/SqlRecordCountTableModel.h"
class ConfigEditor;

class ConfigAnalyze : public ConfigEditor
{
    Q_OBJECT
public:
    ConfigAnalyze();
    Q_INVOKABLE QString getFileName(QString path);
    Q_INVOKABLE void analyzFile(QString path);
    Q_INVOKABLE void insertKeyAndValue(int index);
    Q_INVOKABLE void addField(QString key,QString value);
    Q_INVOKABLE void deleteConfig(int index);
    Q_INVOKABLE void reviseConfig(int index,QString key,QString value);
    Q_INVOKABLE void writeJson();


    void setSectionIndexValue();
    void setKeyIndexvalue();

    void convertJsonToMap(QString path, QJsonObject o, int level);
    void splitJsonFile();
    void jsonToMap();
    void setTable(SqlRecordCountTableModel *table);
    void setCombobox(ComboBoxModel *combobox_section_model,ComboBoxModel *combobox_key_model);


private:
    ComboBoxModel *combobox_section_model_;
    ComboBoxModel *combobox_key_model_;
    SqlRecordCountTableModel *table_model_;
    QMap <QString,QString>  key_value_map_;
    QList< QMap <QString,QMap<QString,QString> > > json_to_map_;

    QJsonObject json_object_;
    int current_section_index_ = 0;
    QList<QJsonObject> json_object_list_;

    QList<QString> key_value_;
    QList<QString> second_key_;

};

#endif // CONFIGANALYZE_H
